﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brainee.Search;

namespace Brainee.Optimization
{
  public class FirstChoiceHillClimbingStrategy : IOptimizationStrategy
  {
    public OptimizationState SelectNeighbor (OptimizationState current, IOptimizationProblem problem)
    {
      IState neighbor = null;
      double value = 0;
      double minValue = problem.Evaluate (current.State);

      do
      {
        neighbor = problem.RandomSuccessor (current.State);
        value = problem.Evaluate (neighbor);
      } while (value < minValue);

      return new OptimizationState (neighbor, value);
    }
  }
}
